#include "thread.hpp"
#include<unistd.h>
#include<vector>
using namespace ThreadModlue;

void* routine(pthread_t tid)
{
    int cnt = 10;
    char name[64]={0};
    pthread_getname_np(tid,name,sizeof(name));
    while(cnt--)
    {
        std::cout << name << std::endl;
        sleep(1);
    }
    return nullptr;
}

int main()
{
    //创建多个线程
    std::vector<Thread<pthread_t>> thread1;
    for(int i = 1; i <= 10; i++)
    {
        thread1.emplace_back(routine);
        sleep(1);
    }

    for(auto& t : thread1)
    {
        t.Start();
        sleep(1);
    }
    for(auto& t : thread1)
    {
        t.Join();
        sleep(1);
    }
    //Thread<int> t(routine,10);
    //t.Start();
    //sleep(5);
    //t.Stop();
    //t.Detach();
    //t.Join();
    //sleep(10);
    return 0;
}
